/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import POJO.DanhMucPOJO;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import ultil.MySqlDataAccessHelper;

/**
 *
 * @author NGUYEN CONG BINH
 */
public class DanhMucDAO {

    public static ArrayList<DanhMucPOJO> layDanhSachDanhMuc() {
        ArrayList<DanhMucPOJO> ds = new ArrayList<DanhMucPOJO>();
        String sql = "SELECT * FROM danhmuc";
        MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
        helper.open();

        ResultSet rs = helper.executeQuery(sql);
        try {
            while (rs.next()) {
                DanhMucPOJO danhmuc = new DanhMucPOJO();
                danhmuc.setMaDanhMuc(rs.getInt("maDanhMuc"));
                danhmuc.setTenDanhMuc(rs.getString("tenDanhMuc"));
                danhmuc.setHinhAnh(rs.getString("hinhAnh"));
                ds.add(danhmuc);
               
            }
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        }
        helper.close();
        return ds;
    }
    
}
